let {loadObject, newObj, trace} = require("../include/common.js");

let pathM = require("path");

function readConf() {
    let cf = require("../conf");
    let gt = os.getGlobalThis();
    gt["gameConf"] = cf;
}

function loadDaemons() {

    os.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    let gt = os.getGlobalThis();
    gt["metaClassSource"] = [];
    // gt["gameConf"] = "";
    // gt["gameObjects"] = "";

    readConf();
    let path = require("path");
    let files = os.fs.deepFiles("adm");

    for (let x in files) {
        //  let file = path.basenameOfprogress(files[x]);
        let data = path.parse(files[x]);
        os.debug(`load daemons file <${data.filePath}>...`);
        newObj(data.filePath);
    }
}

function loadInludes() {

    os.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    let gt = os.getGlobalThis();
    gt["metaClassSource"] = [];
    let path = require("path");
    let files = os.fs.deepFiles("include");
    let {loadMetaClass} = require("../include/core");
    //加载include目录下的文件为对象
    for (let x in files) {
        //os.debug(`文件原始地址是.....${files[x]}`);
        let data = path.parse(files[x]);
        loadMetaClass(data.filePath);
    }
}


/**
 *
 */
function startGame() {
    loadObject("main/gameMain.js").main();
}


function callfunc() {

    let args = arguments;
}




function main() {
    //
    loadInludes();
    loadDaemons();
    startGame();
    return true;
}





